package com.skysail.repository.primary;
import com.skysail.model.primary.UserModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

//@Repository
//@Qualifier("userRepository")
//JpaSpecificationExecutor
//@Repository
public interface UserRepository extends JpaRepository<UserModel,Long> {
    @Query("select t from UserModel t where t.userName = ?1")
    List<UserModel> findByUserName(String userName);

//    @Query("update UserModel o set o.uname = :uname where uno = :uno")
//    public void updUser(@Param("uno")int uno,@Param("uname")String uname);

//    @Query("update UserModel u set u.realName = ?2 where u.id = ?1")
//    @Modifying
//    int updateRealNameById(Long id, String realName);

//    @Query("select t from UserModel t where t.name = :name")
//    UserModel findByUserName(@Param("name") String name);
//
//    /*
//     * 查询全部
//     * */
//    @Query("select t from UserModel t")
//    List<UserModel> find();
//
//
//    /*
//     * 删除  必须加入@Modifying和@Transactional
//     * */
//    @Modifying
//    @Transactional
//    @Query("delete from UserModel u where u.id=:id")
//     int deleteUserById(@Param("id") Integer id);
//
//
//    @Modifying
//    @Transactional
//    @Query("update UserModel u set u.name = :name where u.id=:id")
//    int queryUserById(@Param("id") Integer id,@Param("name") String name);
//　　　　
//    @Query(value = "insert into UserModel value(?,?,?)", nativeQuery = true)
//    @Transactional
//　　@Modifying
//    int countUserBy(@Param("id")Integer id,@Param("name") String name,@Param("password") String password);
}